let userList  =[
  {id:"1",name:"小毅",hooby:"游泳健身"},
  {id:"2",name:"阿木",hooby:"哈啤酒"},
  {id:"3",name:"忘喧",hooby:"偷偷学习"},
  {id:"4",name:"强哥",hooby:"冲冲冲"},
]

/**
 *  模拟调用用户列表接口
 */
export function getUserList(){
  return new Promise(resolve=>{
    setTimeout(()=>{
      const users =  [...userList]
      resolve(users)
    },500)  
  })
}

/**
 * 
 * @param {*} id 
 * @returns userList
 *  根据id删除用户
 */
export function deleteUserById(id){
  return new Promise(resolve=>{
    setTimeout(()=>{
       userList = userList.filter(item=>item.id !== id)
      resolve(userList)
    },500)
  })
}

/**
 * @param {*} user 
 * 新增加一个用户
 */

export function addUser(user){
  return new Promise(resolve=>{
    setTimeout(()=>{
      userList = [...userList,user]
      resolve(userList)
    },500)
  })
}




